
/*

Design Pattern Automation Toolkit.
Application to create applications with emphasis on Design patterns.
And support for round trip engineering.
Copyright (C) 2004 Vineeth Neelakant. nvineeth@gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
using System;
using BusinessLayer;
using InfoClasses;
using dpatoolkit.UILayer;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace dpatoolkit.UILayer
{
    /// <summary>
    /// Summary description for AddProjectDialog.
    /// </summary>
    public class AddProjectForm : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox projSummaryTextBox;
        private System.Windows.Forms.TextBox projAuthorTextBox;
        private System.Windows.Forms.Button cancelButton;
        private System.Windows.Forms.TextBox projNameTextBox;
        private System.Windows.Forms.Button okButton;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public string DPName, Author, Summary;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private GroupBox groupBox3;

        public AddProjectForm(string pname, string pauthor, string psummary, string[] labels)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            if (psummary != null)
                this.projSummaryTextBox.Text = psummary;
            if (pname != null)
                this.projNameTextBox.Text = pname;
            if (pauthor != null)
                this.projAuthorTextBox.Text = pauthor;
            if (labels != null)
            {
                this.groupBox1.Text = labels[0];
                this.groupBox2.Text = labels[1];
                this.groupBox3.Text = labels[2];
            }

        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.okButton = new System.Windows.Forms.Button();
            this.projNameTextBox = new System.Windows.Forms.TextBox();
            this.cancelButton = new System.Windows.Forms.Button();
            this.projAuthorTextBox = new System.Windows.Forms.TextBox();
            this.projSummaryTextBox = new System.Windows.Forms.TextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.SuspendLayout();
            // 
            // okButton
            // 
            this.okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.okButton.Location = new System.Drawing.Point(101, 223);
            this.okButton.Name = "okButton";
            this.okButton.Size = new System.Drawing.Size(75, 23);
            this.okButton.TabIndex = 6;
            this.okButton.Text = "&OK";
            this.okButton.Click += new System.EventHandler(this.okButton_Click);
            // 
            // projNameTextBox
            // 
            this.projNameTextBox.Location = new System.Drawing.Point(15, 19);
            this.projNameTextBox.Name = "projNameTextBox";
            this.projNameTextBox.Size = new System.Drawing.Size(259, 20);
            this.projNameTextBox.TabIndex = 3;
            this.projNameTextBox.Text = "NewProject";
            // 
            // cancelButton
            // 
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.cancelButton.Location = new System.Drawing.Point(217, 223);
            this.cancelButton.Name = "cancelButton";
            this.cancelButton.Size = new System.Drawing.Size(75, 23);
            this.cancelButton.TabIndex = 7;
            this.cancelButton.Text = "&Cancel";
            // 
            // projAuthorTextBox
            // 
            this.projAuthorTextBox.Location = new System.Drawing.Point(15, 18);
            this.projAuthorTextBox.Name = "projAuthorTextBox";
            this.projAuthorTextBox.Size = new System.Drawing.Size(259, 20);
            this.projAuthorTextBox.TabIndex = 4;
            // 
            // projSummaryTextBox
            // 
            this.projSummaryTextBox.Location = new System.Drawing.Point(15, 19);
            this.projSummaryTextBox.Name = "projSummaryTextBox";
            this.projSummaryTextBox.Size = new System.Drawing.Size(259, 20);
            this.projSummaryTextBox.TabIndex = 5;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.projNameTextBox);
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(280, 54);
            this.groupBox1.TabIndex = 8;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Project Name";
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.projAuthorTextBox);
            this.groupBox2.Location = new System.Drawing.Point(12, 77);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(280, 54);
            this.groupBox2.TabIndex = 9;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Author";
            // 
            // groupBox3
            // 
            this.groupBox3.Controls.Add(this.projSummaryTextBox);
            this.groupBox3.Location = new System.Drawing.Point(12, 142);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new System.Drawing.Size(280, 54);
            this.groupBox3.TabIndex = 10;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "Description";
            // 
            // AddProjectForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this.cancelButton;
            this.ClientSize = new System.Drawing.Size(301, 262);
            this.Controls.Add(this.groupBox3);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.cancelButton);
            this.Controls.Add(this.okButton);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Name = "AddProjectForm";
            this.Text = "Add Project";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.groupBox3.ResumeLayout(false);
            this.groupBox3.PerformLayout();
            this.ResumeLayout(false);

        }
        #endregion

        private void okButton_Click(object sender, System.EventArgs e)
        {
            if (this.projNameTextBox.Text.Length == 0)
            {
                ErrorMessage.Show(groupBox1.Text + " cannot be of zero length", "Error");
                return;
            }
            this.Author = this.projAuthorTextBox.Text;
            this.DPName = this.projNameTextBox.Text;
            this.Summary = this.projSummaryTextBox.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
